package Fangfa;

public class fangfa2 {
    public static void main(String[] args) {
        Person2 ming = new Person2();
        ming.setBirth(2008);
        System.out.println(ming.getAge());
    }
}

class Person2{
    private String name;
    private int birth;
    public void setBirth(int birth){
        this.birth = birth;
    }
    //calcAge()是一个private方法，外部代码无法调用，但是，内部方法getAge()可以调用它。
    public int getAge(){
        return calcAge(2019);

    }
    private int calcAge(int currentYear){
        return currentYear -this.birth;
    }
}
